"""
元组不可修改,list可修改，两者可相互转换
元组可自动解包，组包
元组只有一个元素时一定要加上
"""
names = ("大骂","小马","赵","李","王","张","大","小")

names = ("ad") #tuple如果只有一个，一定要加上

print(names)

#自动组包
names = "大骂","小马","赵","李","王","张","大","小"
print(names,type(names))

#自动解包
name1,name2,name3,name4,name5,name6,name7,name8 = names
print(name1,name2,name3,name4,name5,name6,name7,name8)

stu = ("张",21,185.5)
name,age,height = stu
print("name:{} age:{} height{}".format(name,age,height))  # "".format() 此处是点

#数据交换
a = 3
b = 4
b,a = a,b
print(a,b)

#元组不可修改
names_tuple = ("大骂","小马","赵","李","王","张","大","小")
name_list = list(names_tuple) #如果要修改。须先转换成list格式

#list可转换成不可修改的tuple（元组）格式
name_list1 = ["大骂","小马","赵","李","王","张","大","小"]
names_tuple1 = tuple(name_list1) #将list转化为不可修改的tuple
